<template>
  <div class="profile-container">
    <!-- 侧边导航 -->
    <aside class="sidebar">
      <nav class="nav-menu">
        <router-link to="/profile/info" class="nav-item" active-class="active">
          <div :class="{ active: isActive }">
            <i class="icon-people"></i>
            <span>个人首页</span>
          </div>
        </router-link>

        <router-link to="mall" class="nav-item" active-class="active">
          <div :class="{ active: isActive }">
            <i class="icon-shopping-bag"></i>
            <span>商城</span>
          </div>
        </router-link>

        <router-link to="order" class="nav-item" active-class="active">
          <div :class="{ active: isActive }">
            <i class="icon-order"></i>
            <span>我的订单</span>
          </div>
        </router-link>

        <router-link to="pets" class="nav-item" active-class="active">
          <div :class="{ active: isActive }">
            <i class="icon-pet"></i>
            <span>我的宠物</span>
          </div>
        </router-link>

        <router-link to="settings" class="nav-item" active-class="active">
          <div :class="{ active: isActive }">
            <i class="icon-settings"></i>
            <span>设置</span>
          </div>
        </router-link>
      </nav>
    </aside>

    <!-- 子路由视图出口 -->
    <router-view />
  </div>
</template>

<script setup>
import { useRoute } from "vue-router";

const route = useRoute();
</script>

<style lang="less" scoped>
.profile-container {
  display: flex;
  min-height: 100vh;
  background-color: #f5f7fa;
}

/* 侧边导航样式 */
.sidebar {
  width: 180px;
  background-color: #fff;
  box-shadow: 2px 0 5px rgba(0, 0, 0, 0.05);
  padding-top: 20px;
  flex-shrink: 0;
}

.nav-menu {
  padding: 20px 0;
}

.nav-item {
  display: flex;
  align-items: center;
  padding: 12px 25px;
  color: #666;
  cursor: pointer;
  transition: all 0.3s ease;
  font-size: 15px;
  text-decoration: none;

  i {
    margin-right: 12px;
    font-size: 18px;
  }

  &:hover {
    background-color: #f5f5f5;
    color: #8d26e6;
  }

  &.active {
    background-color: #f0e6ff;
    color: #8d26e6;
    border-left: 3px solid #8d26e6;
  }
}

/* 主内容区域样式 */
.main-content {
  flex: 1;
  padding: 30px 40px;
}

.page-title {
  color: #333;
  font-size: 24px;
  margin-bottom: 10px;
}

.page-description {
  color: #666;
  font-size: 15px;
  margin-bottom: 30px;
  line-height: 1.6;
}

/* 功能卡片网格 */
.feature-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 25px;
}

/* 功能卡片样式 */
.feature-card {
  background-color: #fff;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
  transition: transform 0.3s ease, box-shadow 0.3s ease;

  &:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
  }
}

.card-header {
  padding: 18px 20px;
  display: flex;
  align-items: center;

  i {
    font-size: 22px;
    margin-right: 10px;
  }

  h2 {
    font-size: 18px;
    font-weight: 600;
  }
}

.card-description {
  padding: 0 20px 15px;
  color: #666;
  font-size: 14px;
  line-height: 1.5;
}

.card-image {
  width: 100%;
  height: 160px;
  object-fit: cover;
}

.card-action {
  display: block;
  text-align: center;
  padding: 12px 0;
  color: #8d26e6;
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  border-top: 1px solid #f5f5f5;
  margin-top: 15px;

  &:hover {
    color: #a259ff;
    text-decoration: underline;
  }
}

/* 不同卡片的颜色主题 */
.purple-card {
  .card-header {
    background-color: #f9f3ff;
    color: #8d26e6;
  }
}

.blue-card {
  .card-header {
    background-color: #f0f7ff;
    color: #2667e6;
  }
}

.green-card {
  .card-header {
    background-color: #f0fff5;
    color: #26e68d;
  }
}

.yellow-card {
  .card-header {
    background-color: #fffcf0;
    color: #e6b426;
  }
}

.icon-shopping-bag::before {
  content: "🛒";
}

.icon-order::before {
  content: "📝";
}

.icon-pet::before {
  content: "🐾";
}

.icon-settings::before {
  content: "⚙️";
}

/* 响应式调整 */
@media (max-width: 992px) {
  .feature-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .profile-container {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
  }

  .nav-menu {
    display: flex;
    overflow-x: auto;
  }

  .nav-item {
    flex-direction: column;
    flex: 1;
    text-align: center;
    padding: 15px 0;
    border-left: none;
    border-bottom: 3px solid transparent;

    &.active {
      border-left: none;
      border-bottom: 3px solid #8d26e6;
    }

    i {
      margin-right: 0;
      margin-bottom: 5px;
    }
  }
}
</style>
